package com.stu.controller.student;

import com.stu.pojo.PageBean;
import com.stu.result.Result;
import com.stu.serive.NoticeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@Slf4j
@RestController
@RequestMapping("")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;
    /*
        需要前端传入通知类别、关键词、检索时间
     */
    @GetMapping("/notice")//分页查询操作
    public Result notice(@RequestParam(defaultValue = "1") Integer page,//@RequestParam 用于将指定的请求参数赋值给方法中的形参中
                       @RequestParam(defaultValue = "1") Integer pageSize,
                       String informationClass, String key,
                       //@DateTimeFormat 指定时间的格式
                       @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                       @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        log.info("分页查询，参数：{}，{}, {}, {}, {}, {}", page, pageSize,informationClass,key,begin,end);//查询的页面，展示的数据
        //  PageBean 是一个专门用于分页查询的方法，传入指定的参数即可
        PageBean pageBean = noticeService.notice(page, pageSize, informationClass, key, begin, end);
        return Result.success(pageBean);
    }
}
